From 314713c683c6343d2c3156202d5dcc0e139cad05 Mon Sep 17 00:00:00 2001 From: Andrew Cooper Date: Thu, 9 Jul 2015 11:36:22 +0100 Subject: [PATCH] tools/xl: Fix build error following c/s f52fbcf7 CentOS7 complains that 'ret' might be unused, and indeed this is the case for `xl psr-hwinfo --cat`. The logic for selecting which information to print was rather awkward. Introduce a new 'all' which default to true, and is cleared if specific options are selected. This allows for a far more clear logic when choosing whether to print information or not. Signed-off-by: Andrew Cooper CC: Ian Campbell CC: Ian Jackson CC: Wei Liu CC: Chao Peng Acked-by: Ian Campbell Tested-by: Chao Peng --- tools/libxl/xl_cmdimpl.c | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c index 609cf04af9..971209cc22 100644 --- a/tools/libxl/xl_cmdimpl.c +++ b/tools/libxl/xl_cmdimpl.c @@ -8442,8 +8442,8 @@ int main_psr_cat_show(int argc, char **argv) int main_psr_hwinfo(int argc, char **argv) { - int opt, ret; - int cmt = 0, cat = 0; + int opt, ret = 0; + bool all = true, cmt = false, cat = false; static struct option opts[] = { {"cmt", 0, 0, 'm'}, {"cat", 0, 0, 'a'}, @@ -8453,25 +8453,17 @@ int main_psr_hwinfo(int argc, char **argv) SWITCH_FOREACH_OPT(opt, "ma", opts, "psr-hwinfo", 0) { case 'm': - cmt = 1; + all = false; cmt = true; break; case 'a': - cat = 1; + all = false; cat = true; break; } - if (!(cmt | cat)) { - cmt = 1; - cat = 1; - } - - if (cmt) + if (!ret && (all || cmt)) ret = psr_cmt_hwinfo(); - if (ret) - return ret; - - if (cat) + if (!ret && (all || cat)) ret = psr_cat_hwinfo(); return ret; -- 2.30.2